<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>ajax 测试</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
	</head>
	<body>
		<button type="button">测试ajax json数据</button>
	</body>
	<script src="js/jquery-3.3.1.min.js"></script>
	<script type="text/javascript">
		
		$(function(){
			$('button').click(function(){
				$.ajax({
					url:'https://www.sojson.com/open/api/weather/json.shtml?city=%E9%83%91%E5%B7%9E',
					type : 'GET',
					dataType : 'jsonp',
					success: function (data, textStatus, jqXHR) {
                        //解析json数据
                        console.log(data);
                        console.log(textStatus);
                        console.log(jqXHR);
                    },
                    // 错误返回
                    error: function (xhr, textStatus) {
                        console.log('错误');
                        console.log(xhr);
                        console.log(textStatus);
                    }
				})
			})
		})
	</script>
</html>